package com.zhong.oss.controller;

import com.alibaba.nacos.api.exception.NacosException;
import com.zhong.oss.service.FileService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RefreshScope
@RestController
public class FileController {
    @Resource
    private FileService fileService;

    @Value("${storage.service.type:false}")
    private String storageType;


    @GetMapping("/getAllBucket")
    public String getAllBucket(){
        try {
            return fileService.getBucketAll().get(0);
        }catch (Exception e){
            return "获取失败";
        }
    }

    @GetMapping("/getNacos")
    public String testNacos() throws NacosException {
        return this.storageType;
    }
}
